package overall.webPackage
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	import flash.net.URLRequestMethod;
	import flash.utils.ByteArray;
	
	import overall.event.ServerDataEvent;

	public class WebURLLoader
	{
		public function WebURLLoader(url:String)
		{
			_url=url;
			_build();
		}
		private var _urlLoader:URLLoader;
		private var _request:URLRequest;
		private var _url:String;
		private function _build():void
		{

			_urlLoader=new URLLoader;
			_urlLoader.dataFormat=URLLoaderDataFormat.BINARY;
			_urlLoader.addEventListener(Event.COMPLETE,_loadComplete);
			_urlLoader.addEventListener(IOErrorEvent.IO_ERROR,_errLoad);
			_request=new URLRequest;
			
		}
		public function send(byt:ByteArray):void{
			_request=new URLRequest;
			_request.method=URLRequestMethod.POST;
			_request.data=byt;
			_request.url=_url;
			_urlLoader.load(_request);
		}
		private function _loadComplete(e:Event):void
		{
			var pkg:ByteArray=ByteArray(_urlLoader.data);
			WebDataManager.instance.dataCom(pkg);

		}
		private function _errLoad(e:IOErrorEvent):void
		{
			trace("http路径不对");
		}
	}
}